package ControllerLayer;


import ModelLayer.Game;
import ModelLayer.Menu;
import RenderLayer.PauseView;
import RenderLayer.View;
import ServiceLayer.Input;
import android.content.Context;

import com.example.genericrpg_android.GameEngine;

public class PauseMenuController extends Controller {
	Context activity;
	GameEngine mEngine;
	Game mModel;
	private PauseView mPauseView;
	private Menu menu;
	
	public PauseMenuController(Game model, GameEngine engine, Context activity){
		this.activity = activity;
		mModel = model;
		mEngine = engine;
		menu = new Menu(new String[]{"Restart Level", "Quit"}, activity);
		mPauseView = new PauseView(mModel, this, activity);
	}

	@Override
	public void update() {
		
	}
	
	@Override
	public void handleInput(int input) { 
		// TODO Auto-generated method stub
			switch(input){		
		case Input.DOWN: 
			menu.nextOption();
			break;
		case Input.UP: 
			menu.previousOption();
			break;
		case Input.A:
			if (menu.getOption().equals("Restart Level")) {
				mEngine.roomController.restartRoom();
				mEngine.currentController = mEngine.roomController;
			} else if (menu.getOption().equals("Quit")) {
				mEngine.roomController.stopMusic();
				mEngine.setController(Controller.TitleMenuController);
				mEngine.currentController.playMusic();
			}
			
			break;
		case Input.B:
			menu.setOption(0);
			mEngine.setController(Controller.RoomController);
			mEngine.roomController.wakeTimer();
			mEngine.printControllerName();
		
			break;
		}
	}
	
	@Override
	public View getView() {
		return mPauseView;
	}
	
	public Menu getMainMenu() {
		return menu;
	}

	@Override
	public void playMusic() {
		mEngine.roomController.playMusic();
	}

	@Override
	public void stopMusic() {
		mEngine.roomController.stopMusic();
	}

}
